package com.example.util;

import lombok.Data;

@Data
public class Result {
    private Integer code; 
    private String msg;
    private Object data;

    // 方便不需要返回数据的请求，例如新增、修改和删除
    public static Result success() {
        Result result = new Result();
        result.setCode(200);
        result.setMsg("success");
        return result;
    }
    // 方便返回成功数据
    public static Result success(Object data) {
        Result result = success();
        result.setData(data);
        return result;
    }
    // 方便返回错误信息
    public static Result error(String msg) {
        Result result = new Result();
        result.setCode(500);
        result.setMsg(msg);
        return result;
    }
}